<?php 
    $resource = Mage::getResourceModel('vendorconnect/reportvendorcontract');
    $contractModel = $resource->loadContractDetails(Mage::app()->getRequest()->getParam('id',0)); 
    $vendorModel = false;
    if ( $contractModel->getId() )
    {
        $vendorModel = $resource->loadVendorDetails($contractModel->getData('vendor_id')); 
    } 
    //$toDateFormat = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_LONG);
    $toDateFormat = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
    
    $start_date = Mage::app()->getLocale()->date($contractModel->getData('start_date'), Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($toDateFormat);
    $to_date = Mage::app()->getLocale()->date($contractModel->getData('to_date'), Varien_Date::DATETIME_INTERNAL_FORMAT)->toString($toDateFormat);
?>
<?php if( $contractModel->getId() && $vendorModel !== false && $vendorModel->getId() ):?>
<?php $products = $resource->getProductLinkedContract($contractModel->getId()); ?>
<style type="text/css">
.product_list td{
    padding:5px;
}
</style>
<h2>Basic Information</h2>
<table>
    <tr>
        <td>Contract ID:</td>
        <td><?php echo $contractModel->getId() ?></td>
    </tr>
    
    <tr>
        <td>Vendor ID:</td>
        <td><?php echo $vendorModel->getId() ?></td>
    </tr>
    
    <tr>
        <td>Vendor Name:</td>
        <td><?php echo $vendorModel->getName() ?></td>
    </tr>
    
    <tr>
        <td>From Date:</td>
        <td><?php echo $start_date;//Mage::app()->getLocale()->date(strtotime($contractModel->getData('start_date')), null, null, false)->toString($toDateFormat) ?></td>
    </tr>
    <tr>
        <td>To Date:</td>
        <td><?php echo $to_date; ?></td>
    </tr>
    <tr>
        <td>Revenue Sharing (%):</td>
        <td><?php echo $contractModel->getData('revenue_sharing') ?></td>
    </tr>
    <tr>
        <td>Status:</td>
        <td><?php echo ( $contractModel->getData('is_active') == 1) ? 'Active' : 'Inactive'; ?></td>
    </tr>
    
</table>
<h2>Products Linked</h2>
<?php if ( $products ): ?>
<table border="1" style="border-collapse: collapse;min-width:98%;" class="product_list">
<tr>
    <td style="width: 200px;"><strong>ID</strong></td>
    <td><strong>NAME</strong></td>
</tr>
<?php foreach( $products as $product ): ?>
<tr>
    <td><?php echo $product['id'] ?></td>
    <td><?php echo $product['name'] ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<br />
<div><button onclick="javascript:window.print();" style="float: right;margin-right:2%;">Print</button></div>
<br />
<?php else: ?>
<h2>Not found information</h2>
<?php endif; ?>